<?php
namespace app\common\model;

use think\Model;
use think\model\concern\SoftDelete;

class Agent extends Model
{
    use SoftDelete;
	protected $insert  = ['reg_time', 'reg_ip'];

    public function agentInfo()
    {
        return $this->hasOne('AgentInfo', 'agent_id', 'id');
    }

    public function agentLevel()
    {
        return $this->hasOne('AgentLevel', 'id', 'level');
    }

	protected function setPasswordAttr($value)
    {
        return md5($value);
    }

    protected function setRegTimeAttr()
    {
        return time();
    }

    protected function setRegIpAttr()
    {
        return request()->ip();
    }

    protected function setEndTimeAttr($value)
    {
        return strtotime($value);
    }
    
}